package com.huawei.appmarket.service.appdetail.view.card;

import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.huawei.appgallery.foundation.service.common.protocol.AppDetailActivityProtocol;
import com.huawei.appgallery.foundation.service.common.protocol.AppDetailActivityProtocol.Request;
import com.huawei.appgallery.foundation.ui.framework.cardframe.bean.BaseCardBean;
import com.huawei.appgallery.jsonkit.api.JsonBean;
import com.huawei.appmarket.service.appdetail.bean.detail.DetailClickBean;
import com.huawei.appmarket.service.appdetail.bean.detail.DetailClickBean.DetailItem;
import java.util.List;
import o.azb;
import o.cii;
import o.cjk;
import o.cjm;
import o.cjo;
import o.ckt;
import o.drl;
import o.emz;
import o.ewm.h;
import o.ewm.j;

public class DetailClickCard extends drl implements OnClickListener {
    private boolean ʼ;
    private DetailClickBean ʽ;

    public DetailClickCard() {
        this.ʼ = true;
        this.ॱ = 309;
    }

    public View ˊ(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        this.ˊ = layoutInflater.inflate(h.ˊˋ, null);
        return this.ˊ;
    }

    public boolean ˊ(List<JsonBean> list) {
        int i = 0;
        if (list == null || list.size() <= 0) {
            return false;
        }
        this.ʽ = (DetailClickBean) list.get(0);
        if (this.ʽ == null || this.ʽ.ॱ() == null || this.ʽ.ॱ().size() <= 0) {
            return false;
        }
        LinearLayout linearLayout = (LinearLayout) this.ˊ.findViewById(j.ʽʻ);
        azb.ˏ(linearLayout);
        TextView textView = (TextView) this.ˊ.findViewById(j.ʼﾞ);
        TextView textView2 = (TextView) this.ˊ.findViewById(j.ꜟᐝ);
        azb.ˏ(textView2);
        TextView textView3 = (TextView) this.ˊ.findViewById(j.ʼʹ);
        azb.ˏ(textView3);
        TextView textView4 = (TextView) this.ˊ.findViewById(j.ʿﾟ);
        azb.ˏ(textView4);
        TextView textView5 = (TextView) this.ˊ.findViewById(j.ʽˈ);
        ImageView imageView = (ImageView) this.ˊ.findViewById(j.ʼꜞ);
        View findViewById = this.ˊ.findViewById(j.ʼꞌ);
        textView.setText(this.ʽ.ˊ());
        int size = this.ʽ.ॱ().size();
        while (i < size && i <= 2) {
            switch (i) {
                case 0:
                    ˎ(textView2, i);
                    break;
                case 1:
                    ˎ(textView3, i);
                    break;
                case 2:
                    ˎ(textView4, i);
                    break;
                default:
                    break;
            }
            i++;
        }
        linearLayout.setTag(this.ʽ.ॱॱ());
        if (this.ʼ) {
            findViewById.setOnClickListener(new ckt(this));
        } else {
            textView5.setVisibility(4);
            imageView.setVisibility(4);
        }
        return true;
    }

    private void ˎ(TextView textView, int i) {
        textView.setText(((DetailItem) this.ʽ.ॱ().get(i)).ॱ());
        if (this.ʼ) {
            textView.setOnClickListener(new ckt(this));
        }
        textView.setId(i);
        textView.setVisibility(0);
    }

    public void onClick(View view) {
        String ॱॱ;
        int id = view.getId();
        if (view.getId() == j.ʼꞌ) {
            ॱॱ = this.ʽ.ॱॱ();
        } else if (id < 0 || id >= this.ʽ.ॱ().size()) {
            ॱॱ = null;
        } else {
            ॱॱ = ((DetailItem) this.ʽ.ॱ().get(id)).ˎ();
        }
        if (!TextUtils.isEmpty(ॱॱ)) {
            if (ॱॱ.startsWith("html|")) {
                int indexOf = ॱॱ.indexOf(124);
                if (indexOf != -1) {
                    ॱॱ = ॱॱ.substring(indexOf + 1);
                }
                emz.ॱ(view.getContext(), "internal_webview", ॱॱ);
                return;
            }
            BaseCardBean baseCardBean = new BaseCardBean();
            baseCardBean.ॱ(ॱॱ);
            baseCardBean.ˉ(this.ʽ.ͺˏ());
            Context context = view.getContext();
            if (!cii.ˊ().ˊ(context, baseCardBean)) {
                cjo appDetailActivityProtocol = new AppDetailActivityProtocol();
                appDetailActivityProtocol.ˏ(new Request(this.ʽ.ॱॱ(), null));
                cjk.ˎ().ˋ(context, new cjm("appdetail.activity", appDetailActivityProtocol));
            }
        }
    }

    public void ˊ(boolean z) {
        this.ʼ = z;
    }
}
